<?php


namespace app\cms\home\api\shopping;


use app\cms\model\merchant\merchantModel;
use iflow\Response;
use iflow\Router\Controller;
use iflow\Router\implement\Request\GetMapping;

#[Controller('%cmsHome%/merchant')]
class merchant
{
    /**
     * 获取商户列表
     * @param string $merchant_name
     * @param int $merchant_type
     * @return Response
     * @throws \think\db\exception\DbException
     */
    #[GetMapping]
    public function get(string $merchant_name, int $merchant_type): Response
    {
        return (new merchantModel()) -> getMerchantList($merchant_name, $merchant_type);
    }

    #[GetMapping]
    public function getNearbyMerchant(string $lat, string $lng, string $merchant_name, int $merchant_type): Response {
        // 获取附近 商户
        if ($lat === '' || $lng === '') {
            return message() -> parameter_error('获取定位失败， 请重试');
        }
        return (new merchantModel()) -> getNearbyMerchant($lat, $lng, $merchant_name, $merchant_type);
    }
}